package com.azh.springcloud.controller;

import com.azh.springcloud.entities.CommonResult;
import com.azh.springcloud.entities.Payment;
import com.azh.springcloud.service.PaymentFerignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderFeginController {
    @Resource
    private PaymentFerignService paymentFerignService;

    @GetMapping(value = "/consumer/payment/get/{id}")
    public CommonResult<Payment> getPaymentByid(@PathVariable("id") Long id){
        return paymentFerignService.getPaymentByid(id);
    }
    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout()
    {
        // OpenFeign客户端一般默认等待1秒钟,超时则报错
        return paymentFerignService.paymentFeignTimeout();
    }

}
